

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class H extends SizedBox {
  H(double gap): super(height: gap);
}

class W extends SizedBox {
  W(double gap): super(width: gap);
}

class D extends SizedBox {
  D({
    double width = double.infinity,
    double height = 1,
    Color color = const Color(0x0f000000)}): super(width: width, height: height,
      child: Divider(
        thickness: height,
        color: color,
      )
  );
}

// padding divider
class PD extends StatelessWidget {

  final double size;
  final double paddingLeft;
  final double paddingRight;
  final Color? color;

  const PD(this.size, this.paddingLeft, this.paddingRight, {Key? key, this.color = const Color(0x0f000000)}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(padding: EdgeInsets.only(left: paddingLeft, right:  paddingRight), child:
      SizedBox(width: double.infinity, height: size, child:
        Divider(color: color)
      )
    );
  }

}

class VD extends SizedBox {
  VD(height, {
    double width = 1,
    Color color = const Color(0x0f000000)}): super(width: width, height: height,
      child: VerticalDivider(
        width: width,
        thickness: width,
        color: color,
      )
  );
}

//dash divider
class DD extends StatelessWidget {

  final double height;
  final Color color;
  final double dashWidth;
  final double paddingLeft;
  final double paddingRight;

  const DD({Key? key,
    this.height = 1,
    this.color = const Color(0x0f000000),
    this.dashWidth = 5,
    this.paddingLeft = 0,
    this.paddingRight = 0
  }) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        final boxWidth = constraints.constrainWidth() - paddingLeft - paddingRight;
        final dashHeight = height;
        final dashCount = (boxWidth / (2 * dashWidth)).floor();
        return Padding(padding: EdgeInsets.only(left: paddingLeft, right: paddingRight), child: Flex(
          children: List.generate(dashCount, (_) {
            return SizedBox(
              width: dashWidth,
              height: dashHeight,
              child: DecoratedBox(
                decoration: BoxDecoration(color: color),
              ),
            );
          }),
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          direction: Axis.horizontal,
        ));
      },
    );
  }
  
}